package com.atguigu.springfirst;


import org.apache.logging.log4j.core.Logger;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestUser {
//    private Logger logger = LoggerFactory.getLogger(TestUser.class);

    @Test
    public void testUserAdd(){
        ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
        User user = (User) context.getBean("user");
        System.out.println("1:"+user);

        System.out.printf("2:");
        user.add();
    }

//    反射创建类
    @Test
    public void testUserObject1() throws Exception {
        Class clazz=Class.forName("com.atguigu.springfirst.User");
        User user = (User) clazz.getDeclaredConstructor().newInstance();
        System.out.println(user);
    }
}
